from tools_algorithm import *


class Solution:
    def appealSum(self, s: str) -> int:
        c = ans = 0
        h = {}
        for i, v in enumerate(s):
            c += i - h[v] if v in h else i + 1
            h[v] = i
            ans += c
        return ans


s = Solution()
print(s.appealSum("abbca"))

c = []
for i in range(100):
    c.append(chr(random.randint(0, 25) + ord("a")))
print("".join(c))
